using Godot;
using System;

public partial class Level02 : Node2D
{
	[Export]
	public float speed = 2f;

	public Level02()
	{
	}

	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		var new_position = this.Position;
		// 将节点沿 X 轴向左移动
		new_position.X = 600;
		new_position.Y = 250;
		// 更新节点的位置
		this.Position = new_position;
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
		if (Input.IsKeyPressed(Key.Left))
		{
			// 获取当前节点的位置
			var new_position = this.Position;
			// 将节点沿 X 轴向左移动
			new_position.X -= speed;
			// 更新节点的位置
			this.Position = new_position;
		}
		else if (Input.IsKeyPressed(Key.Right))
		{
			// 获取当前节点的位置
			var new_position = this.Position;
			// 将节点沿 X 轴向左移动
			new_position.X += speed;
			// 更新节点的位置
			this.Position = new_position;
		}
		else if (Input.IsKeyPressed(Key.Up))
		{
			// 获取当前节点的位置
			var new_position = this.Position;
			// 将节点沿 X 轴向左移动
			new_position.Y -= speed;
			// 更新节点的位置
			this.Position = new_position;
		}
		else if (Input.IsKeyPressed(Key.Down))
		{
			// 获取当前节点的位置
			var new_position = this.Position;
			// 将节点沿 X 轴向左移动
			new_position.Y += speed;
			// 更新节点的位置aa
			this.Position = new_position;
		}
	}

}
